don't leak as many GCs
authorcinamod <cinamod>
Fri, 3 Oct 2003 13:51:41 +0000 (13:51 +0000)
committercinamod <cinamod>
Fri, 3 Oct 2003 13:51:41 +0000 (13:51 +0000)
modules/engines/ms-windows/ChangeLog.old
modules/engines/ms-windows/wimp_style.c

index dce1818e1df121b0a35b0919064446e5f3d0b71b..d619689e2d9d2f81b9979a79a0654a1e76a0bdd3 100755 (executable)
@@ -1,3 +1,7 @@
+2003-10-02  Dom Lachowicz <cinamod@hotmail.com>\r
+\r
+       * src/wimp_style.c: Deallocate used HDCs\r
+       \r
 2003-10-01  Dom Lachowicz <cinamod@hotmail.com>\r
 \r
        * src/wimp_style.c: Only set the delays if the param is installed. Silly gtk - \r
index f60b227fa0000cb2bdc13928ebdd17dec790e21c..fb5a212b986d019566fb87b6b5c0723a1b0900ad 100755 (executable)
@@ -151,6 +151,8 @@ get_system_font(SystemFontType type, LOGFONT *out_lf)
 static char *
 sys_font_to_pango_font (SystemFontType type, char * buf)
 {
+  HDC hDC;
+  HWND hwnd;
   LOGFONT lf;
   int pt_size;
   const char * weight;
@@ -194,13 +196,19 @@ sys_font_to_pango_font (SystemFontType type, char * buf)
       else
        style="";
 
-      pt_size = -MulDiv(lf.lfHeight, 72,
-                        GetDeviceCaps(GetDC(GetDesktopWindow()),
-                                      LOGPIXELSY));
-      sprintf(buf, "%s %s %s %d", lf.lfFaceName, style, weight, pt_size);
+       hwnd = GetDesktopWindow();
+       hDC = GetDC(hwnd);
+       if (hDC) {
+               pt_size = -MulDiv(lf.lfHeight, 72,
+                             GetDeviceCaps(hDC,LOGPIXELSY));
+               ReleaseDC(hwnd, hDC);
+       } else
+               pt_size = 10;
 
-      return buf;
-    }
+    sprintf(buf, "%s %s %s %d", lf.lfFaceName, style, weight, pt_size);
+
+    return buf;
+   }
 
   return NULL;
 }